package com.taobao.action;

import com.taobao.pojo.Filter;
import com.taobao.pojo.TBMessage;
import com.taobao.server.ConfigServer;
import com.taobao.server.FilterServer;
import com.taobao.tools.TBMessageDialog;
import com.taobao.ui.widget.FilterWidget;

public class FilterAction extends CommonAction {

    private FilterServer filterServerSingle;
    private ConfigServer configServer;

    @Override
    public void doAction(Object uiObject) {
        FilterWidget filterWidget = (FilterWidget) uiObject;
        filterServerSingle.setFilter(filterWidget.getPojo(Filter.class));
        this.saveFilterToINI(uiObject);
    }

    private void saveFilterToINI(Object uiObject) {
        FilterWidget filterWidget = (FilterWidget) uiObject;
        Filter filter = filterWidget.getPojo(Filter.class);
        TBMessage message = configServer.updateObject(ConfigServer.FILTER, filter);
        TBMessageDialog.messageHandler(filterWidget.getShell(), message);
    }

}
